using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 负责子弹的所有行为
/// </summary>
public class BulletController : MonoBehaviour
{
    [Header("移动与物理参数")]
    [Tooltip("子弹飞行速度")]
    public float speed = 20f;
    
    [Header("子弹相关")]
    private Rigidbody2D _rb;
    
    /// <summary>
    /// 子弹运行和销毁
    /// </summary>
    void Start()
    {
        _rb = GetComponent<Rigidbody2D>();
        //给子弹一个向上的力
        _rb.velocity = transform.up * speed;
        //3秒后自动销毁
        Destroy(gameObject, 3f);
    }
}
